package exclude

import (
	"go.manyji.com/lib/encoding/json"
	"go.manyji.com/lib/log"
	"sieve_admin_server/app/server"
)

func GetSysDefine(c *server.Context, uid int) (data []byte, err error) {

	log.Info("GetSysDefine")
	list := make(map[string]interface{})
	db := &DB{
		AdminDB: server.DB(),
	}
	userInfo, err := db.GetUserInfo(uid)
	if err != nil {
		log.Info("err", err)
		data, err = nil, err
	} else {
		userInfo["swzl"] = c.HasNotAdminPermission("user/auth.swzl")
		userInfo["swzg"] = c.HasNotAdminPermission("user/auth.swzg")
		userInfo["sw"] = c.HasNotAdminPermission("user/auth.sw")
		userInfo["yyzg"] = c.HasNotAdminPermission("user/auth.yyzg")
		userInfo["yyzl"] = c.HasNotAdminPermission("user/auth.yyzl")
		list["UserInfo"] = userInfo
	}
	list["ResourceList"] = server.GetModTree(uid)
	allUserList := GetAllBusinessList(c)
	list["AllUserList"] = allUserList["AllUserList"]
	list["BusinessList"] = allUserList["BusinessList"]

	regionList := region.QueryRegion(db)
	if len(regionList) > 0 {
		list["Region1"] = regionList["Region1"]
		list["Region2"] = regionList["Region2"]
		list["Region3"] = regionList["Region3"]
	}
	data, err = json.Marshal(list)

	return
}
